package gjtx7;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Document {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        SimpleDateFormat df=new SimpleDateFormat("hh:mm:ss");
        Date d=new Date();
        System.out.println("输入一个文件名:");
        String str=in.next();
        String s1=in.nextLine();
        File f=new File(str);
        try {
            FileOutputStream out=new FileOutputStream(f,true);
            System.out.println("请输入：");
            while (true){
                String sr=in.nextLine();
                if (!sr.equals("quit")) {
                    String dfs = df.format(d.getTime());
                    out.write((dfs + "  " + sr + "\n").getBytes());
                }else {
                    out.close();
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
